package com.acme.gprs.server;

final class GPRSApplianceClientId {
	public final static String IMEI_UNDEFINED = "UNDEFINED";
	private String hostAddress;
	private int port;
	private String imei;

	GPRSApplianceClientId(String hostAddress, int port) {
		this.hostAddress = hostAddress;
		this.port = port;
		this.imei = IMEI_UNDEFINED;
	}

	public String getHostAddress() {
		return hostAddress;
	}

	public int getPort() {
		return port;
	}

	public String getImei() {
		return imei;
	}

	public void setImei(String imei) {
		this.imei = imei;
	}

	@Override
	public boolean equals(Object obj) {
		boolean equals = false;
		if (obj != null && obj instanceof GPRSApplianceClientId) {
			GPRSApplianceClientId other = (GPRSApplianceClientId) obj;
			if( other.getImei()!=null && this.imei!=null ){
				equals = other.getImei().equals(this.imei);
			}else{
				equals = false;
			}
		}
		return equals;
	}

	@Override
	public int hashCode() {
		return imei.hashCode();
	}

	@Override
	public String toString() {
		return imei;
	}
}